//
//  CalendarRecordCell.m
//  ForYourBeauty
//
//  Created by Kelly xu on 2019/6/2.
//  Copyright © 2019 changrenTech. All rights reserved.
//

#import "CalendarRecordCell.h"
#import "CalendarColCell.h"

@interface CalendarRecordCell()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,CalenderImgUploadDelegate>{
    
}
@property(nonatomic,weak)IBOutlet UICollectionView *mainCollection;
@property(nonatomic,strong)NSMutableArray *recordList;
@end
@implementation CalendarRecordCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.backgroundColor = [UIColor clearColor];
    // Initialization code
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
    flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    self.mainCollection.delegate = self;
    self.mainCollection.dataSource = self;
    self.mainCollection.collectionViewLayout = flowLayout;
    self.mainCollection.pagingEnabled = YES;
    [self.mainCollection registerNib:[UINib nibWithNibName:@"CalendarColCell" bundle:nil] forCellWithReuseIdentifier:@"CalendarColCell"];
    self.mainCollection.backgroundColor = [UIColor clearColor];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(void)setCellValue:(NSMutableArray*)recordList{
    [self.recordList removeAllObjects];
    [self.recordList addObjectsFromArray:recordList];
    [self.mainCollection reloadData];
}
#pragma mark - instance
-(NSMutableArray*)recordList{
    if (!_recordList) {
        _recordList = [[NSMutableArray alloc]init];
    }
    return _recordList;
}
#pragma mark - collectionViewDelegate
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return self.recordList.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    CalendarColCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CalendarColCell" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor clearColor];
    [cell setCellValue:[self.recordList objectAtIndex:indexPath.row]];
    cell.delegate = self;
    return cell;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    return CGSizeMake(DEVICE_WIDTH, 374);
    
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
    return 0;
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
    return 10;
}
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
    return UIEdgeInsetsMake(0, 0, 0, 0);
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    
}
-(void)goRecordUploaded:(UserUseListModel *)model{
    if ([self.delegate respondsToSelector:@selector(addFeel:)]) {
        [self.delegate addFeel:model];
    }
}
-(void)goTextUploaded:(UserUseListModel*)model{
    if ([self.delegate respondsToSelector:@selector(addFeelText:)]) {
        [self.delegate addFeelText:model];
    }
}
@end
